package com.wsoft.hr.pm.controller;

import com.github.pagehelper.PageInfo;
import com.wsoft.hr.pm.entity.HrPmGradeOrgEntity;
import com.wsoft.hr.pm.query.grade.org.HrPmGradeOrgInsertQuery;
import com.wsoft.hr.pm.query.grade.org.HrPmGradeOrgListQuery;
import com.wsoft.hr.pm.query.grade.org.HrPmGradeOrgUpdateQuery;
import com.wsoft.hr.pm.service.IHrPmGradeOrgService;
import com.wsoft.response.ResponsePage;
import com.wsoft.response.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 考核评级组织表 Controller
 *
 * @Author Z001
 * @Date 2025-03-01 08:35:23
 */
@RestController
@Tag(name = "考核评级组织表")
@RequestMapping("/hrPmGradeOrg")
public class HrPmGradeOrgController {

    @Resource
    private IHrPmGradeOrgService hrPmGradeOrgService;

    @Operation(summary = "考核评级组织表-分页查询", description = "考核评级组织表 -分页查询")
    @PostMapping("/list")
    public ResponseResult list(@RequestBody @Valid HrPmGradeOrgListQuery query) {
        PageInfo<HrPmGradeOrgEntity> page = hrPmGradeOrgService.listHrPmGradeOrg(query);
        return ResponseResult.success(ResponsePage.restPage(page));
    }

    @Operation(summary = "考核评级组织表-详情", description = "考核评级组织表-详情")
    @GetMapping("/get")
    public ResponseResult get(@RequestParam("id") Long id) {
        return ResponseResult.success(hrPmGradeOrgService.getInfo(id));
    }

    @Operation(summary = "新增-考核评级组织表", description = "新增-考核评级组织表")
    @PostMapping("/insert")
    public ResponseResult insert(@RequestBody @Valid HrPmGradeOrgInsertQuery query) {
        boolean b =  hrPmGradeOrgService.insertHrPmGradeOrg(query);
        if (b) {
            return ResponseResult.success("[sys.msg.success]");
        } else {
            return ResponseResult.failed("[sys.msg.failed]");
        }
    }

    @Operation(summary = "更新-考核评级组织表", description = "更新-考核评级组织表")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody @Valid HrPmGradeOrgUpdateQuery query) {
        boolean b =  hrPmGradeOrgService.updateHrPmGradeOrg(query);
        if (b) {
            return ResponseResult.success("[sys.msg.success]");
        } else {
            return ResponseResult.failed("[sys.msg.failed]");
        }
    }

    @Operation(summary = "删除-考核评级组织表",description = "删除-考核评级组织表")
    @GetMapping("/delete")
    public ResponseResult delete(@RequestParam("id") Long id) {
        boolean b = hrPmGradeOrgService.delete(id);
        if (b) {
            return ResponseResult.success("[sys.msg.success]");
        } else {
            return ResponseResult.failed("[sys.msg.failed]");
        }
    }
}
